package com.guoxianwei.scm.web.actions;

import java.io.Serializable;

import javax.servlet.http.HttpSession;

import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.action.ActionBeanContext;
import net.sourceforge.stripes.action.SimpleMessage;

import com.guoxianwei.scm.domain.Account;

 public abstract class AbstractActionBean implements ActionBean, Serializable {

	private static final long serialVersionUID = -1767714708233127983L;

	protected static final String ERROR = "/WEB-INF/jsp/common/Error.jsp";

	protected transient ActionBeanContext context;

	protected void setMessage(String value) {
		context.getMessages().add(new SimpleMessage(value));
	}

	public ActionBeanContext getContext() {
		return context;
	}

	public void setContext(ActionBeanContext context) {
		this.context = context;
	}

	public Account getAccount() {
		HttpSession session = context.getRequest().getSession();
		AccountActionBean actionBean = (AccountActionBean) session
				.getAttribute("accountBean");
		if (actionBean != null)
			return actionBean.getAccount();
		return new Account();
	}
}
